﻿<!DOCTYPE html>
<html>
  <head>
    <title>addcommodity</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <link href="resources/css/jquery-ui-themes.css" type="text/css" rel="stylesheet"/>
    <link href="resources/css/axure_rp_page.css" type="text/css" rel="stylesheet"/>
    <link href="data/styles.css" type="text/css" rel="stylesheet"/>
    <link href="files/addcommodity/styles.css" type="text/css" rel="stylesheet"/>
    <script src="resources/scripts/jquery-1.7.1.min.js"></script>
    <script src="resources/scripts/jquery-ui-1.8.10.custom.min.js"></script>
    <script src="resources/scripts/prototypePre.js"></script>
    <script src="data/document.js"></script>
    <script src="resources/scripts/prototypePost.js"></script>
    <script src="files/addcommodity/data.js"></script>
    <script type="text/javascript">
      $axure.utils.getTransparentGifPath = function() { return 'resources/images/transparent.gif'; };
      $axure.utils.getOtherPath = function() { return 'resources/Other.html'; };
      $axure.utils.getReloadPath = function() { return 'resources/reload.html'; };
    </script>
    <style>
        .divleave{
          margin-top: 20px;
        }
        tr{
          height: 40px;
        }
        .button {
            background-color: #4CAF50; /* Green */
            border: none;
            border-radius: 5px;
            color: white;
            padding: 15px 32px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
        }
    </style>
  </head>
  <body style="text-align:center;width:100%;height:974px;">
    
    <div style="width:100%;height:974px;background:rgb(255, 255, 255);text-align:center;">

          

      <form action="/BackstageCommodity/addCommodity" method="get">
        <table style="position:absolute;left:40%;top:100px;">
          <tr>
            <td colspan="2"><span><h1>创建商品</h1></span></td>
          </tr>
          <tr>
              <td><span><input type="button" value="搜索用户" onclick="finduser();" style="background-color: #4CAF50;border: none;border-radius: 5px;color: white;text-align: center;display: inline-block;text-decoration: none;font-size: 16px;width:80px;height:36px;" ></span></td>
              <td><span><input id="userId" type="text" name="userId" value="" title="用户id"></span></td>
          </tr>
          <tr style="height:0px;" id="usernametr">
            <td><span id="jingyu"></span></td><td><span id="username"></span></td>
          </tr>
          <tr>
            <td><span>商品名</span></td>
            <td><span><input type="text" value="" name="commodityName" title="商品名"></span></td>
          </tr>
          <tr>
            <td><span>商品价格</span></td>
            <td><span><input type="number" value="" name="commodityPrise" title="商品价格"></span></td>
          </tr>
          <tr>
            <td><span>商品目标</span></td>
            <td><span><input type="text" value="" name="commodityTarget" title="商品目标"></span></td>
          </tr>
          <tr>
            <td><span>商品描述</span></td>
            <td><span><input type="text" value="" name="commodityDescribe" title="商品描述"></span></td>
          </tr>
          <tr>
            <td>
                <span>
                    商品完好程度
                  </span>
            </td>
            <td>
                <span>
                    <select style="width:173px;height:21px;" name="commodityComplete" >
                      <option value="选择新旧程度">选择新旧程度</option>
                      <option value="9成9新">9成9新</option>
                      <option value="9成新">9成新</option>
                      <option value="8成新">8成新</option>
                      <option value="表面有划痕">表面有划痕</option>
                      <option value="有轻微变形">有轻微变形</option>
                    </select>
                  </span>
            </td>
          </tr>
          <tr>
            <td><span>商品缩略图</span></td>
            <td><span><input type="text" value="" name="commodityThumbnail" title="商品缩略图"></span></td>
          </tr>
          
          <tr>
            <td><span><input type="submit" value="确定提交" class="button" /></span></td>
            <td><input type="reset" value="重置输入" class="button" ></td>
          </tr>
        </table>
      </form>
    </div>
    <script>
      function finduser(){
        var userId = document.getElementById('userId').value;
        var hp = new XMLHttpRequest();
        hp.open('get','/BackstageCommodity/finduser?userId='+userId,true);
        hp.send();
        hp.onreadystatechange = function(){
          if(200 == hp.status){
            if(4 == hp.readyState){
              // alert(hp.responseText);
              var json = eval("("+hp.responseText+")");
              if(json.length == 2 && json[1].result == 'ok'){
                document.getElementById('usernametr').style.height = "40px";
                document.getElementById('jingyu').innerText = "已找到用户:";
                document.getElementById('username').innerText = json[0].userName;
              }else if(json.length == 1 && json[0].result == 'sorry'){
                alert("抱歉，请先注册成为会员");
              }
            }
          }
        }
      }
    </script>
  </body>
</html>
